#include "TestModel.h"
#include "learnopengl/Shader.h"
#include "Mesh.h"
#include "Imgui/imgui.h"
#include <iostream>

extern Camera camera;

namespace Test {
	TestModel::TestModel() :translation(0, -10, -10), objModel("..\\..\\OpenGLResource\\model\\nanosuit\\nanosuit.obj")
	{
		ourShader = new Shader("ObjVert.glsl", "ObjFrag.glsl");
	}
	void TestModel::Enter()
	{

		ourShader->use();
#pragma endregion
		#pragma region GLSetting
		glEnable(GL_DEPTH_TEST);
#pragma endregion
	}
	void TestModel::Leave()
	{
		delete ourShader;
	}
	void TestModel::OnRender()
	{
		glClearColor(0.2f, 0.3f, 0.4f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		//MVP and Shader
		ourShader->use();
		glm::mat4 model;
		glm::mat4 view;
		glm::mat4 projection;
		model = glm::translate(glm::mat4(1.0f), translation);
		view = camera.GetViewMatrix();
		projection = glm::perspective(glm::radians(camera.Zoom), ScreenWidth / ScreenHeight, 0.1f, 100.0f);
		ourShader->setMat4("model", model);
		ourShader->setMat4("view", view);
		ourShader->setMat4("projection", projection);
		objModel.Draw(ourShader);
	}
	void TestModel::OnImguiRender()
	{
		ImGui::SliderFloat3("translation", &translation.x, -100.0f, 100.0f);

	}
	void TestModel::Update(float deltaTime)
	{
	}
}